package com.bicon.botu.account.rpc.service;

import com.alibaba.fastjson.JSONObject;
import com.bicon.botu.account.dto.AccountLogDTO;
import com.bicon.botu.account.service.IAccountLogService;
import com.bicon.botu.core.base.common.controller.BaseController;
import com.bicon.botu.core.base.common.entity.BaseResult;
import com.bicon.botu.core.base.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 张凡
 * @date 2018/1/4 15:28
 */
@Service
public class AccountLogRpcService extends BaseController {

    @Autowired
    IAccountLogService iAccountLogService;

    /**
     * 获取多个账户日志
     *
     * @param userIds 多个用户id
     * @param type    类型：0-打开app时，1-唤醒时
     * @return
     */
    @RequestMapping(value = "/getAccountLogs", method = RequestMethod.POST)
    public BaseResult getAccountLogs(@RequestParam String userIds, @RequestParam String type) {
        if (StringUtils.isAnyBlank(userIds, type)) {
            return sendResult400();
        }
        List<String> list = JSONObject.parseArray(userIds, String.class);
        List<AccountLogDTO> accountLogDTOS = iAccountLogService.getAccountLogBatch(list, type);
        return sendResult200(accountLogDTOS);
    }
}
